package com.zsj.arithmetic.ListAndMap;

/**
 * 找出数组中连续1的个数
 */
public class ListDemo1 {
    public int seriesOne(int [] n){
        int maxCount =0,count =0;
        for (int i = 0; i < n.length; i++) {
            if (n[i] ==1){
                count++;
            }else if(n[i] ==0) {
                maxCount = Math.max(maxCount,count);
                count = 0;
            }
        }
        maxCount = Math.max(maxCount,count);
        return maxCount;
    }
}
